package com.bnz.portal.client;

import com.bnz.common.entity.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;
//fallback: 处理熔断的一种方法，需要指定一个实现了当前接口的class对象
// @FeignClient(value="zyg-user",fallback = UserClientFallBack.class)
@Component
//fallbackFactory: 处理熔断的另一种方法：实现FallbackFactory<UserClient>接口
@FeignClient(value="zyg-user",fallbackFactory = UserClientFallBackFactory.class)
public interface UserClient {
    //1. 查询所有用户
    @GetMapping("/user/list")
    @ResponseBody
    R findAll();

    //2. 查询单个用户
    @GetMapping("/user/{id}")
    @ResponseBody
    R findById(@PathVariable("id") String id);
}
